home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
character.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
42KB
|
1,172 lines
-- character state machine
-- called by init
-- this: characterGO
function initCharacter()
-- this function is called when the characters is newly created
-- set the time the character needs from getting up to getting to work
this.storeData("workPrepareTime", tonumber(readConfig("Game", "workPrepareTime")));
-- set the minimum time the character thinks between actions
this.storeData("minThinkTime", tonumber(readConfig("Game", "minThinkTime")));
-- set the maximal time the character thinks between actions
this.storeData("maxThinkTime", tonumber(readConfig("Game", "maxThinkTime")));
end
beginStateMachine()
onEnter(function(msg)
-- preload animations
--print("character::onEnter archtype: " .. getArchtypeSuffix(this));
-- walk
local wso = this.walkSO;
wso.preloadAnimation(archize(this, "stand1"));
wso.preloadAnimation(archize(this, "stand2"));
wso.preloadAnimation(archize(this, "stand3"));
wso.preloadAnimation(archize(this, "stand4"));
wso.preloadAnimation(archizeWalk(this, "stand-walkLFF-"));
wso.preloadAnimation(archizeWalk(this, "walkRFF-walkLFF-"));
wso.preloadAnimation(archizeWalk(this, "walkLFF-walkRFF-"));
-- mimic
local mso = this.mimicSO;
mso.preloadAnimation("mimicEyeBlink");
mso.preloadAnimation("mimicNeutral1");
mso.preloadAnimation("mimicNeutral2");
mso.preloadAnimation("mimicNeutral3");
mso.preloadAnimation("mimicEyeClose");
mso.preloadAnimation("mimicSmile1");
mso.preloadAnimation("mimicSmile2");
mso.preloadAnimation("mimicSmile3");
mso.preloadAnimation("mimicSmile4");
mso.preloadAnimation("mimicSmile5");
mso.preloadAnimation("mimicAngry1");
mso.preloadAnimation("mimicSad1");
end)
onMsg("init", function(msg)
initCharacter();
end )
onMsg("buildMenu", function(msg)
local currentCharacter = getStateObjectFromID(msg.sender);
print("character buildMenu " .. currentCharacter.getCharacterName().. "->" .. this.getCharacterName());
-- build the pie menu
clearPieMenu();
local button ;
-- local bed = this.getObjectWithActivity("sleep");
-- if (bed and bed.hasBehavior("")) then
-- button = addPieMenuButton("pm_getIntimateBed", "getIntimateBed");
-- button.addDescription(ACTIVITY, "getIntimateBed");
--button.addDescription(DONTQUEUE, "true");
-- end
local ibed = getInteractionBed(this, currentCharacter);
if (ibed) then
-- button = addPieMenuButton("pm_kissBed", "kissBed");
-- button.addDescription(ACTIVITY, "kissBed");
button = addPieMenuButton("pm_pettingBed", "pettingBed");
button.addDescription(ACTIVITY, "pettingBed");
local bothMale = (
(currentCharacter.getGameObjectServer().getCharacter(ELAINE).isTransgender()) and
(not currentCharacter.getGameObjectServer().getCharacter(MIKE).isTransgender())
);
local bothHomo = (
(currentCharacter.getGameObjectServer().getCharacter(ELAINE).isTransgender()) and
(currentCharacter.getGameObjectServer().getCharacter(MIKE).isTransgender())
);
if (not bothMale) and (not bothHomo) then
button = addPieMenuButton("pm_sexBed", "sexBed");
button.addDescription(ACTIVITY, "sexBed");
end
else
end
if ((not bed) and (not ibed) and (not (this.isSwimming()))) then
--if ((not bed) and (not ibed)) then
local romanceButton = addPieMenuButton("pm_romance", "");
romanceButton.addIcon("guiIconRelationshipRomantic");
button = romanceButton.addPieMenuButton("pm_talkRelation", "talk", "Relation");
button.addDescription(ACTIVITY, "talkRelation");
button = romanceButton.addPieMenuButton("pm_talkCompliment", "talk", "Compliment");
button.addDescription(ACTIVITY, "talkCompliment");
button = romanceButton.addPieMenuButton("pm_holdNice", "holdNice");
button.addDescription(ACTIVITY, "holdNice");
button = romanceButton.addPieMenuButton("pm_kissFriendly", "kiss", "Friendly");
button.addDescription(ACTIVITY, "kissFriendly");
button = romanceButton.addPieMenuButton("pm_kissIntimate", "kiss", "Intimate");
button.addDescription(ACTIVITY, "kissIntimate");
button = romanceButton.addPieMenuButton("pm_talkILoveYou", "talk", "ILoveYou");
button.addDescription(ACTIVITY, "talkILoveYou");
if (canMarry(currentCharacter, this)) then
button = romanceButton.addPieMenuButton("pm_talkMarryMe", "talkMarryMe", "");
button.addIcon("guiIconRelationErotic");
button.addIcon("guiIconRelationFriendship");
button.addDescription(ACTIVITY, "talkILoveYou");
end
local eroticButton = addPieMenuButton("pm_erotic", "");
eroticButton.addIcon("guiIconLibido");
button = eroticButton.addPieMenuButton("pm_talkFlirt", "talk", "Flirt");
button.addDescription(ACTIVITY, "talkFlirt");
button = eroticButton.addPieMenuButton("pm_kissSexy", "kissSexy", "Sexy"); -- special kiss
button.addDescription(ACTIVITY, "kissSexy");
if (currentCharacter.isMale()) then
button = eroticButton.addPieMenuButton("pm_holdBehind", "holdBehind");
button.addDescription(ACTIVITY, "holdBehind");
end;
button = eroticButton.addPieMenuButton("pm_getIntimateBed", "getIntimateBed");
button.addDescription(ACTIVITY, "getIntimateBed");
local sofa = this.getObjectWithActivity("sit");
if (sofa and sofa.hasBehavior("sofa")) then
button = eroticButton.addPieMenuButton("pm_getIntimateSofa", "getIntimateSofa");
button.addDescription(ACTIVITY, "kissIntimate");
end
local otherButton = addPieMenuButton("pm_other", "");
otherButton.addIcon("guiIconSpass");
button = otherButton.addPieMenuButton("pm_talkJoke", "talk", "Joke");
button.addDescription(ACTIVITY, "talkJoke");
button = otherButton.addPieMenuButton("pm_talkTease", "talk", "Tease");
button.addDescription(ACTIVITY, "talkTease");
local friendshipButton = addPieMenuButton("pm_friendship", "");
friendshipButton.addIcon("guiIconRelationshipFriendship");
button = friendshipButton.addPieMenuButton("pm_talkCasual", "talk", "Casual");
button.addDescription(ACTIVITY, "talkCasual");
button = friendshipButton.addPieMenuButton("pm_talkGossip", "talk", "Gossip");
button.addDescription(ACTIVITY, "talkGossip");
button = friendshipButton.addPieMenuButton("pm_talkComfort", "talk", "Comfort");
button.addDescription(ACTIVITY, "talkComfort");
button = friendshipButton.addPieMenuButton("pm_talkHobby", "talk", "Hobby");
button.addDescription(ACTIVITY, "talkHobby");
-- button = addPieMenuButton("pm_kissFriendly", "kiss", "Friendly");
-- button.addDescription(ACTIVITY, "kissFriendly");
--
-- button = addPieMenuButton("pm_kissNice", "kiss", "Nice");
-- button.addDescription(ACTIVITY, "kissNice");
--
-- button = addPieMenuButton("pm_kissIntimate", "kiss", "Intimate");
-- button.addDescription(ACTIVITY, "kissIntimate");
--
-- button = addPieMenuButton("pm_kissSexy", "kissSexy", "Sexy"); -- special kiss
-- button.addDescription(ACTIVITY, "kissSexy");
-- button = addPieMenuButton("pm_talkCasual", "talk", "Casual");
-- button.addDescription(ACTIVITY, "talkCasual");
--
-- button = addPieMenuButton("pm_talkGossip", "talk", "Gossip");
-- button.addDescription(ACTIVITY, "talkGossip");
--
-- button = addPieMenuButton("pm_talkFlirt", "talk", "Flirt");
-- button.addDescription(ACTIVITY, "talkFlirt");
--
-- button = addPieMenuButton("pm_talkHobby", "talk", "Hobby");
-- button.addDescription(ACTIVITY, "talkHobby");
--
-- button = addPieMenuButton("pm_talkRelation", "talk", "Relation");
-- button.addDescription(ACTIVITY, "talkRelation");
--
-- button = addPieMenuButton("pm_talkJoke", "talk", "Joke");
-- button.addDescription(ACTIVITY, "talkJoke");
--
-- button = addPieMenuButton("pm_talkCompliment", "talk", "Compliment");
-- button.addDescription(ACTIVITY, "talkCompliment");
--
-- button = addPieMenuButton("pm_talkILoveYou", "talk", "ILoveYou");
-- button.addDescription(ACTIVITY, "talkILoveYou");
--
-- button = addPieMenuButton("pm_talkArgue", "talk", "Argue");
-- button.addDescription(ACTIVITY, "talkArgue");
--
-- button = addPieMenuButton("pm_talkComfort", "talk", "Comfort");
-- button.addDescription(ACTIVITY, "talkComfort");
--
-- button = addPieMenuButton("pm_talkTease", "talk", "Tease");
-- button.addDescription(ACTIVITY, "talkTease");
--button = addPieMenuButton("pm_talkCutscene", "talkCutscene");
end;
-- local sofa = this.getObjectWithActivity("sit");
-- local wsoMachineName = this.walkSO.getStateMachine().getName();
-- print("wsoMachineName: " , wsoMachineName);
-- if (sofa and sofa.hasBehavior("sofa") and (wsoMachineName == "sofaChar")) then
-- button = addPieMenuButton("pm_getIntimateSofa", "getIntimateSofa");
-- button.addDescription(ACTIVITY, "kissIntimate");
-- end
local hasGift = holdsObject(currentCharacter, "gift");
--print("hasGift: " , hasGift);
if (hasGift) then
button = addPieMenuButton("pm_giveGift", "giveGift");
button.addDescription(ACTIVITY, "giveGift");
end
end )
-- generic talk
onMsg("talk", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the suffix
local talkType = msg.data;
print(">>>>> onMsg talk" .. msg.data .." character " .. character.getCharacterName() .. " -> " .. getCharacterName());
--if (instantAbortIfNotIdle(character, this)) then return end;
if instantAbortIfUnhappy(character, "talk" .. talkType, this) then return end;
-- check if the activity is possible
-- if (activityPossible(character, msg.name, this) and isIdle(this)) then
if (activityPossible(character, "talk" .. talkType, this)) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("talk", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
wsoContext.storeData("talkType", talkType);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("talkType", talkType);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "talk", wsoContext);
wso.queueStateMachine("interaction.talk", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "talk", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.talk", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_talk"..talkType, interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
-- start action for this character
-- if (thisWso.walkToActionPoint(interactionPoint.getPassiveActionPoint())) then
-- thisWso.queueMessage("waitForChar", this, "talk", thisWsoContext);
-- else
-- print("no path found");
-- instantAbort(this, EMOTICON_NOPATH, "emoThink")
-- end
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
--sendMsg("sad", character.mimicSO);
-- instantAbort(character, EMOTICON_SHY, "emoRefuseChar", this)
instantAbort(character, EMOTICON_SAD, "emoRefuseChar", this)
end
end )
-- cutscene talk
onMsg("talkMarryMe", function(msg)
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
print(">>+>> onMsg talkMarryMe character " .. character.getCharacterName() .. " -> " .. getCharacterName());
-- marry here
instantAbort(character);
end )
-- cutscene talk
onMsg("talkCutscene", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
--if (instantAbortIfNotIdle(character, this)) then return end;
print(">>>>> onMsg talkCutscene character " .. character.getCharacterName() .. " -> " .. getCharacterName() .. " topic " .. msg.data);
--if (character.isSwimming() or this.isSwimming()) then return end;
-- if (character.isSwimming() or this.isSwimming()) then
-- print("no path found");
-- instantAbort(character, EMOTICON_NOPATH, "emoThink")
-- return
-- end;
-- walk to the interaction point
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
wsoContext.storeData("topic", msg.data);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("waitLong", isIdle(this));
thisWsoContext.storeData("topic", msg.data);
local interactionPoint = findInteractionPoint("talk", character);
if (interactionPoint) then
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "talkCutscene", wsoContext);
wso.queueStateMachine("interaction.talkCutscene", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "talkCutscene", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.talkCutscene", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_talkCutscene", interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
else
print("talkCutscene - no path found");
--instantAbort(character, EMOTICON_NOPATH, "emoThink")
-- wso.queueStateMachine("interaction.talkCutscene", this, wsoContext);
-- thisWso.queueStateMachine("interaction.talkCutscene", this, thisWsoContext);
character.sendDelayedMsg("talking", getGameObjectServer().mission, 500, msg.data);
end
else
print("talkCutscene - no interaction point found");
--instantAbort(character, EMOTICON_CANNOT, "emoThink")
-- wso.queueStateMachine("interaction.talkCutscene", this, wsoContext);
-- thisWso.queueStateMachine("interaction.talkCutscene", this, thisWsoContext);
character.sendDelayedMsg("talking", getGameObjectServer().mission, 500, msg.data);
end
end )
-- generic kiss
onMsg("kiss", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the suffix
local kissType = msg.data;
--if (instantAbortIfNotIdle(character, this)) then return end;
if instantAbortIfUnhappy(character, "kiss" .. kissType, this) then return end;
-- local actionPointName = "kiss";
-- if (kissType == "Sexy") actionPointName = "talk"; end; -- hack, bad animation
-- check if the activity is possible
--if (activityPossible(character, "kiss" .. kissType, this) and isIdle(this)) then
if (activityPossible(character, "kiss" .. kissType, this)) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("kiss", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
wsoContext.storeData("kissType", kissType);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("kissType", kissType);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "kiss", wsoContext);
wso.queueStateMachine("interaction.kiss", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "kiss", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.kiss", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_kiss"..kissType , interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
--sendMsg("sad", character.mimicSO);
--instantAbort(character, EMOTICON_SHY, "emoRefuseChar", this)
instantAbort(character, EMOTICON_SAD, "emoRefuseChar", this)
end
end )
-- kissSexy kiss special: has loop
onMsg("kissSexy", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the suffix
local kissType = msg.data;
--if (instantAbortIfNotIdle(character, this)) then return end;
if instantAbortIfUnhappy(character, msg.name, this) then return end;
-- check if the activity is possible
--if (activityPossible(character, msg.name, this) and isIdle(this)) then
if (activityPossible(character, msg.name, this)) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("talk", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
wsoContext.storeData("kissType", kissType);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("kissType", kissType);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "kissSexy", wsoContext);
wso.queueStateMachine("interaction.kissSexy", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "kissSexy", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.kissSexy", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_kissSexy", interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
-- -- start action for this character
-- if (thisWso.walkToActionPoint(interactionPoint.getPassiveActionPoint())) then
-- thisWso.queueMessage("waitForChar", this, "kissSexy", thisWsoContext);
-- else
-- print("no path found");
-- instantAbort(this, EMOTICON_NOPATH, "emoThink")
-- end
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
--sendMsg("sad", character.mimicSO);
--instantAbort(character, EMOTICON_SHY, "emoRefuseChar", this)
instantAbort(character, EMOTICON_SAD, "emoRefuseChar", this)
end
end )
-- getIntimateSofa
onMsg("getIntimateSofa", function(msg)
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the sofa on wcjich this character is sitting
local sofa = this.getObjectWithActivity("sit");
if ((not sofa) or (not sofa.hasBehavior("sofa"))) then
instantAbort(character, EMOTICON_NOSOFA, "emoThink");
return
end
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
local thisActionPointName = thisWso.retrieveData("actionPointName");
if (not thisActionPointName) then
print("getIntimateSofa: thisActionPointName == nil");
instantAbort(character, EMOTICON_CANNOT, "emoThink");
return
end
local actionPointName = nil;
local mirrorAnims = false;
local thisMale = this.isMale();
print("--------------getIntimateSofa passive character on actionpoint:" .. thisActionPointName .. " male:" .. tostring(thisMale));
if (thisActionPointName == "sit1") then
if (thisMale) then
actionPointName = "sit2";
else
actionPointName = "sit2";
mirrorAnims = true;
end
elseif (thisActionPointName == "sit2") then
if (thisMale) then
actionPointName = "sit3";
else
actionPointName = "sit1";
end
elseif (thisActionPointName == "sit3") then
if (thisMale) then
actionPointName = "sit2";
mirrorAnims = true;
else
actionPointName = "sit2";
end
else
print("getIntimateSofa passive character on unknown actionpoint:" .. thisActionPointName)
instantAbort(character, EMOTICON_CANNOT, "emoThink");
end
print("--------------getIntimateSofa active character to actionpoint:" .. actionPointName .. " mirrorAnims:" .. tostring(mirrorAnims));
local actionPoint = character.getClosestFreeActionPoint(character, sofa, {actionPointName});
print("--------------getIntimateSofa getClosestFreeActionPoint returned actionpoint:" .. actionPoint.getName());
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
if (wso.walkToActionPoint(actionPoint)) then
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeStateObject("sofa", sofa);
wsoContext.storeData("sitState", "waitIntimate");
wsoContext.storeData("activePart", true);
wsoContext.storeData("mirrorAnims", mirrorAnims);
thisWso.storeStateObject("partner", wso);
thisWso.storeStateObject("sofa", sofa);
thisWso.storeData("activePart", false);
thisWso.storeData("mirrorAnims", mirrorAnims);
print("getIntimateSofa sendMsg waitIntimate & queueStateMachine sofaChar.sitDownToGetIntimate");
--wso.queueStateMachine("sofaChar.sitDownToGetIntimate", this, wsoContext);
wso.queueStateMachine("sofaChar.sitDown", sofa, wsoContext);
sendMsg("waitIntimate", thisWso);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink");
return
end
-- thisWso.setState("waitIntimate");
-- thisWso.queueStateMachine("sofaChar.waitIntimate", this, thisWsoContext);
else
print("mike.lua::getIntimateSofa: no action point found " .. actionPointName);
instantAbort(character, EMOTICON_CANNOT, "emoThink");
end
end )
-- getIntimateSofaShortcut
onMsg("getIntimateSofaShortcut", function(msg)
print("onMsg getIntimateSofaShortcut");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
local possible, mirrorAnims = getSofaIteractionInfo(character, this);
wso.storeStateObject("partner", thisWso);
wso.storeData("activePart", true);
wso.storeData("mirrorAnims", mirrorAnims);
thisWso.storeStateObject("partner", wso);
thisWso.storeData("activePart", false);
thisWso.storeData("mirrorAnims", mirrorAnims);
--thisWso.setState("waitIntimate");
sendMsg("waitIntimate", thisWso);
end )
-- getIntimate
onMsg("getIntimateBed", function(msg)
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the bed on wcjich this character is laying
local bed = this.getObjectWithActivity("sleep");
print("onMsg getIntimate: no partner in bed");
if instantAbortIfUnhappy(character, "getIntimateBed", this) then return end;
if (not bed) then
print(" getIntimate: no partner in bed");
--if (instantAbortIfNotIdle(character, this)) then return end;
local freeBed, actionPoint1, actionPoint2 = findBedForInteraction(this, character);
if (freeBed) then
-- get the walk state object
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
if (wso.walkToActionPoint(actionPoint2)) then
-- if (thisWso.walkToActionPoint(actionPoint1)) then
print("free double bed found");
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
wsoContext.storeData("actionPointName", actionPoint2.getName());
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeStateObject("bed", freeBed);
wsoContext.storeData("activePart", true);
thisWsoContext.storeData("actionPointName", actionPoint1.getName());
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeStateObject("bed", freeBed);
thisWsoContext.storeData("activePart", false);
--thisWso.queueStateMachine("doublebedChar.layDownToGetIntimate", this, thisWsoContext);
wso.queueStateMachine("doublebedChar.layDownToGetIntimate", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
--passiveMsg.set("enterStateMachine", this.getUniqueID(), "doublebedChar.layDownToGetIntimate", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "doublebedChar.layDownToGetIntimate", thisWsoContext);
local walkQueueEntry = this.pushWalkActionPoint("pm_getIntimateBed", actionPoint1, false, passiveMsg, true);
--this.pushQueueEntry("pm_getIntimateBed");
--setTopQueueEntry(this, "pm_getIntimateBed");
-- else
-- print("no path found");
-- instantAbort(this, EMOTICON_NOPATH, "emoThink")
-- end
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("getIntimate: no action point found of layDown1, layDown2");
instantAbort(character, EMOTICON_NODOUBLEBED, "emoThink")
end
else
local actionPoint = character.getClosestFreeActionPoint(character, bed, {"layDown1", "layDown2"});
if (actionPoint) then
-- get the walk state object
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeStateObject("bed", bed);
wsoContext.storeData("activePart", true);
thisWso.storeStateObject("partner", wso);
thisWso.storeStateObject("bed", bed);
thisWso.storeData("activePart", false);
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("doublebedChar.layDownToGetIntimate", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
thisWso.setState("waitIntimate");
else
print("getIntimate: no action point found of layDown1, layDown2");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end
end )
-- getIntimateBedShortcut
onMsg("getIntimateBedShortcut", function(msg)
print("onMsg getIntimateBedShortcut");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the bed on wcjich this character is laying
local bed = this.getObjectWithActivity("lie");
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
wso.storeStateObject("partner", thisWso);
wso.storeStateObject("bed", bed);
wso.storeData("activePart", true);
thisWso.storeStateObject("partner", wso);
thisWso.storeStateObject("bed", bed);
thisWso.storeData("activePart", false);
--wso.setState("waitIntimate");
thisWso.setState("waitIntimate");
end )
-- kissBed
onMsg("kissBed", function(msg)
print("character onMsg kissBed");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
if not getInteractionBed(this, character) then
instantAbort(character)
return
end
character.walkSO.storeData("activePart", true);
this.walkSO.storeData("activePart", false);
sendMsg("kissBed", character.walkSO);
sendMsg("kissBed", this.walkSO);
end )
-- pettingBed
onMsg("pettingBed", function(msg)
print("character onMsg pettingBed");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
if not getInteractionBed(this, character) then
instantAbort(character)
return
end
character.walkSO.storeData("activePart", true);
this.walkSO.storeData("activePart", false);
sendMsg("pettingBed", character.walkSO);
sendMsg("pettingBed", this.walkSO);
end )
-- sexBed
onMsg("sexBed", function(msg)
print("character onMsg sexBed");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
if not getInteractionBed(this, character) then
instantAbort(character)
return
end
character.walkSO.storeData("activePart", true);
this.walkSO.storeData("activePart", false);
sendMsg("sexBed", character.walkSO);
sendMsg("sexBed", this.walkSO);
end )
-- holdNice
onMsg("holdNice", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
--if (instantAbortIfNotIdle(character, this)) then return end;
if instantAbortIfUnhappy(character, msg.name, this) then return end;
-- check if the activity is possible
--if (activityPossible(character, msg.name, this) and isIdle(this)) then
if (activityPossible(character, msg.name, this)) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("hug", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "holdNice", wsoContext);
wso.queueStateMachine("interaction.holdNice", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "holdNice", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.holdNice", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_holdNice", interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
-- -- start action for this character
-- if (thisWso.walkToActionPoint(interactionPoint.getPassiveActionPoint())) then
-- thisWso.queueMessage("waitForChar", this, "holdNice", thisWsoContext);
-- else
-- print("no path found");
-- instantAbort(this, EMOTICON_NOPATH, "emoThink")
-- end
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
sendMsg("sad", character.mimicSO);
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- holdBehind
onMsg("holdBehind", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
--if (instantAbortIfNotIdle(character, this)) then return end;
if instantAbortIfUnhappy(character, msg.name, this) then return end;
-- check if the activity is possible
if (activityPossible(character, msg.name, this)) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("behind", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "holdBehind", wsoContext);
wso.queueStateMachine("interaction.holdBehind", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.holdBehind", thisWsoContext);
local walkQueueEntry = this.pushWalkActionPoint("pm_holdBehind", interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
-- -- start action for this character
-- if (thisWso.walkToActionPoint(interactionPoint.getPassiveActionPoint())) then
-- thisWso.queueMessage("waitForChar", this, "holdBehind", thisWsoContext);
-- else
-- print("no path was found");
-- this.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
-- sendMsg("emoThink", this.walkSO);
-- end
else
print("no path was found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
sendMsg("sad", character.mimicSO);
instantAbort(character, EMOTICON_SAD, "emoRefuseChar")
end
end )
-- onMsg("imBackAtHome", function(msg)
-- if (this.getRememberGift() == true) and (holdObject(this, "gift")) then
-- print("looking for partner to give the gift")
-- local partner = getStateObjectFromID(msg.sender);
-- this.setRememberGift(false);
-- if (partner) then
-- sendMsg("giveGift", partner);
-- end
-- end
-- end )
-- giveGift
onMsg("giveGift", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
print("onMsg giveGift from " .. character.getCharacterName() .. " to " .. this.getCharacterName());
--if (instantAbortIfNotIdle(character, this)) then return end;
-- check if the activity is possible
if (activityPossible(character, msg.name, this)) then
if (holdsObject(character, "gift")) then
-- walk to the interaction point
local interactionPoint = findInteractionPoint("talk", character);
if (interactionPoint) then
-- get the walk state objects
local wso = character.walkSO;
local thisWso = this.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
local thisWsoContext = StateMachineContext();
-- store the partners
wsoContext.storeStateObject("partner", thisWso);
wsoContext.storeData("activePart", true);
thisWsoContext.storeStateObject("partner", wso);
thisWsoContext.storeData("activePart", false);
thisWsoContext.storeData("waitLong", isIdle(this));
-- start action for other character
if (wso.walkToActionPoint(interactionPoint.getActiveActionPoint())) then
-- wso.queueMessage("waitForChar", this, "giveGift", wsoContext);
wso.queueStateMachine("interaction.giveGift", this, wsoContext);
-- queue walk and state change msg for this(passive) character
local passiveMsg = QueuedMessage();
-- passiveMsg.set("waitForChar", this.getUniqueID(), "giveGift", thisWsoContext);
passiveMsg.set(Message.MSG_RESERVED_EnterStateMachine, this.getUniqueID(), "interaction.giveGift", thisWsoContext);
print("-----------------------> passive character pushWalkActionPoint");
local walkQueueEntry = this.pushWalkActionPoint("pm_giveGift", interactionPoint.getPassiveActionPoint(), false, passiveMsg, true);
-- -- start action for this character
-- if (thisWso.walkToActionPoint(interactionPoint.getPassiveActionPoint())) then
-- thisWso.queueMessage("waitForChar", this, "giveGift", thisWsoContext);
-- else
-- print("no path found");
-- instantAbort(this, EMOTICON_NOPATH, "emoThink")
-- end
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no interaction point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
print("no gift to give")
sendMsg("sad", character.mimicSO);
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
-- activity not possible
print(msg.name .. " not possible");
sendMsg("sad", character.mimicSO);
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- play as this char
onMsg("playAsThis", function(msg)
getGameObjectServer().setCurrentCharacter(this);
end )
endStateMachine()